import { BasicColumn, FormSchema } from '@/components/Table';
import { h, ref } from 'vue';
import { Tag } from 'ant-design-vue';
import { ywUserSelectList, ywDeptSelectList } from '@/api/heng/ywManage';
import { ApiSelect } from '@/components/Form';
import util from '@/utils/util';

import { useMessage } from '@/hooks/web/useMessage';
import Ainput from '@/views/bookManage/components/account/Ainput.vue';
import { VxeFormItemProps, VxeGridPropTypes } from '@/components/VxeTable';
import { changeEnd } from 'codemirror';
import { style } from '@logicflow/extension/es/bpmn-elements/presets/icons';

type CheckedType = boolean | string | number;
// BasicColumn[]

// VxeColumnPropTypes.CellRender

/**
 */
export const vxeTableColumns: VxeGridPropTypes.Columns = [

  {
    title: '名称',
    field: 'userName2',
    showOverflow: 'title',
    formatter: ({ cellValue, row, column }) => {
      let val = row.userName;
      if (row.userType=='manage_user'&&row.userName) {
        val = `${val}(经理)`;
      }
      if (row.userType=='manage_user'&&!row.userName) {
        val = `经理(空缺)`;
      }
      return val;
    },
    align: 'center',
  },

  {
    title: '部门',
    field: 'deptName',
    align: 'center',
  },
  {
    title: '线上审批单号',
    field: 'approveNo',
    align: 'center',
  },
  {
    title: '线上金额',
    field: 'userPrice',
    showOverflow: 'title',
    align: 'center',
  },
  {
    title: '线下金额',
    field: 'lindDownPrice',
    showOverflow: 'title',
    align: 'center',
  },
  {
    title: '线下金额输入框',
    field: 'lindDownPrice',
    showOverflow: 'title',
    align: 'center',
    cellRender:{
      name:"VxeInput",
      events: {
        input (cellParams, event: InputEvent) {
          const { row } = cellParams;
          let val = row.lindDownPrice;
          let value=0;
          if(val){
            value+=parseFloat(val);
          }
          if(row.userPrice){
            value+=row.userPrice;
          }
          row.totalPrice=value;
          // console.log("---row.totalPrice:"+row.totalPrice);
        }
      }
    }
  },
  {
    title: '小计',
    field: 'totalPrice',
    showOverflow: 'title',
    align: 'center',
    formatter: ({ cellValue, row, column }) => {
      let val = 0;
      if(row.userPrice){
        val+=row.userPrice;
      }
      if(row.lindDownPrice){
        val+=parseFloat(row.lindDownPrice);
      }
      return val;
    }
  },

];


